package com.test50_JVM;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

/**
 * 虚引用，PhantomReference
 */
public class Demo08_PhantomReference {

    public static void main(String[] args) {
        Object obj = new Object();
        ReferenceQueue<Object> queue = new ReferenceQueue<>();
        PhantomReference<Object> ref = new PhantomReference<>(obj, queue);  // 虚引用
        System.err.println(ref.get());  // 无法获取数据
    }
}
